import store from '@/vuex/store.js'

let file = {
  path:null,
  name:null,
  type:null
};
let r = null;
var route = '_doc/audio/';//存放音频

export function startReady() {
  r = plus.audio.getRecorder()
  if (r == null) {
    alert('未准备好')
    r = plus.audio.getRecorder()
    return
  }
  r.record({filename: route}, function (p) {
    plus.io.resolveLocalFileSystemURL(p, function (entry) {
      file.path = entry.toLocalURL();
      file.name = entry.name;
      file.type = 'audio/amr';
    }, function (e) {

    })
  }, function (e) {
    alert('录制失败' + e.message)
  })
}

export function stopReady(fil) {
  r.stop();
  setTimeout(()=>{
    fil(file);
  },500)

}
